package com.itmuch.cloud.feign;

import com.itmuch.cloud.config.FeignConfig;
import com.itmuch.cloud.dto.UserDTO;
import com.itmuch.cloud.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@FeignClient(name = "microservice-provider-user", configuration = FeignConfig.class)
public interface UserFeignClient {


    @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
    public User findById(@PathVariable Long id);

    @GetMapping("/user/{id}/orders/{orderId}")
    String getOrder(@PathVariable("id") Long userId, @PathVariable("orderId") Long orderId);

    @GetMapping("/user/search")
    String search1(@RequestParam("name") String name, @RequestParam("age") Integer age, @RequestParam("size") Integer size);

    @GetMapping("/user/search")
    String search2(@RequestParam Map<String, Object> params);

    @PostMapping("/user/create")
    String createUser(@RequestBody UserDTO user);

    /**
     * 单文件上传
     *
     * @param file
     * @param description
     * @return
     */
    @PostMapping(value = "/user/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadFile(@RequestPart("file") MultipartFile file, @RequestPart("description") String description);
}
